import React from 'react';

import Constants from '../../common/Constants';
import ResponseConstants from '../../common/ResponseConstants';
import BaseAction from '../common/BaseAction';

export default class HeartLoveRquestDeleteSelfDataAction extends BaseAction {
  constructor(props) {
    super(props);

    this.moduleType = Constants.MODULE_TYPE.HEART;
    this.name = "HeartLoveRquestDeleteSelfDataAction";
  }

  _dealCall(caller, data) {
    caller.setState({
      viewStatus:1,
      statusText:"",
    })
  }

  finish(data, isSucceed, response) {
    let detail = "";
    let success = false;
    if(response.status == ResponseConstants.status_deal_success) {
      detail = "删除成功";
      success = true;
    }
    else if (response.status == ResponseConstants.status_unauthorized) {
      detail = data.detail ? data.detail : "登录已过期";
    }
    else if (response.status == ResponseConstants.status_server_error) {
      detail = "服务器出错";
    }
    else if (response.status == ResponseConstants.status_bad_request) {
      detail = data.detail ? data.detail : "错误请求";
    }
    else {
      detail = "数据错误";
    }
    this.caller.setState({
      viewStatus: response.status,
      isSucceed:success,
      statusText: detail,
      commitDataFinish:true,
    })
  }
}
